
package com.estar.assistsurvy.fragment;

import java.util.ArrayList;

import com.estar.assistsurvy.R;
import com.estar.assistsurvy.entity.ScalePagerItem;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;

public class CarRightFragment extends BaseFragment implements OnClickListener{

	private Button backBumper,boxCover,rightBackFender,rightBackDoor,rightFrontDoor,
	rightFrontFender;
	private boolean isclick1=false,isclick2=false,isclick3=false,isclick4=false,isclick5=false,isclick6=false;
	private ArrayList<ScalePagerItem> list;
	private ScalePagerItem item1,item2,item3,item4,item5,item6;
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		if(view==null){
			view=inflater.inflate(R.layout.fragment_carright, null);
		}
		return view;
	}
	
	@Override
	public void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
		initView();
	}
	
	private void initView(){
		backBumper=find(R.id.backBumper);
		backBumper.setOnClickListener(this);
		boxCover=find(R.id.boxCover);
		boxCover.setOnClickListener(this);
		rightBackFender=find(R.id.rightBackFender);
		rightBackFender.setOnClickListener(this);
		rightBackDoor=find(R.id.rightBackDoor);
		rightBackDoor.setOnClickListener(this);
		rightFrontDoor=find(R.id.rightFrontDoor);
		rightFrontDoor.setOnClickListener(this);
		rightFrontFender=find(R.id.rightFrontFender);
		rightFrontFender.setOnClickListener(this);
		
		list=new ArrayList<>();
		item1=new ScalePagerItem();
		item1.setTitles("后杠");
		item1.setScaleImages(R.drawable.pic_car08);
		item2=new ScalePagerItem();
		item2.setTitles("备箱盖");
		item2.setScaleImages(R.drawable.pic_car09);
		item3=new ScalePagerItem();
		item3.setTitles("右后叶子板");
		item3.setScaleImages(R.drawable.pic_car10);
		item4=new ScalePagerItem();
		item4.setTitles("右后门");
		item4.setScaleImages(R.drawable.pic_car11);
		item5=new ScalePagerItem();
		item5.setTitles("右前门");
		item5.setScaleImages(R.drawable.pic_car12);
		item6=new ScalePagerItem();
		item6.setTitles("右前叶子板");
		item6.setScaleImages(R.drawable.pic_car13);
	}

	public ArrayList<ScalePagerItem> getList(){
		return list;
	}
	
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.backBumper:
			if(isclick1){
				isclick1=false;
				list.remove(item1);
				backBumper.setBackgroundResource(R.drawable.demaged_frame);
				backBumper.setTextColor(getActivity().getResources().getColor(R.color.colorTextOrange));
			}else{
				isclick1=true;
				list.add(item1);
				backBumper.setBackgroundResource(R.drawable.demaged_frame1);
				backBumper.setTextColor(getActivity().getResources().getColor(R.color.colorBgWhite));
			}
			
			break;

		case R.id.boxCover:
			if(isclick2){
				isclick2=false;
				list.remove(item2);
				boxCover.setBackgroundResource(R.drawable.demaged_frame);
				boxCover.setTextColor(getActivity().getResources().getColor(R.color.colorTextOrange));
			}else{
				isclick2=true;
				list.add(item2);
				boxCover.setBackgroundResource(R.drawable.demaged_frame1);
				boxCover.setTextColor(getActivity().getResources().getColor(R.color.colorBgWhite));
			}
			break;

		case R.id.rightBackFender:
			if(isclick3){
				isclick3=false;
				list.remove(item3);
				rightBackFender.setBackgroundResource(R.drawable.demaged_frame);
				rightBackFender.setTextColor(getActivity().getResources().getColor(R.color.colorTextOrange));
			}else{
				isclick3=true;
				list.add(item3);
				rightBackFender.setBackgroundResource(R.drawable.demaged_frame1);
				rightBackFender.setTextColor(getActivity().getResources().getColor(R.color.colorBgWhite));
			}
			break;

		case R.id.rightBackDoor:
			if(isclick4){
				isclick4=false;
				list.remove(item4);
				rightBackDoor.setBackgroundResource(R.drawable.demaged_frame);
				rightBackDoor.setTextColor(getActivity().getResources().getColor(R.color.colorTextOrange));
			}else{
				isclick4=true;
				list.add(item4);
				rightBackDoor.setBackgroundResource(R.drawable.demaged_frame1);
				rightBackDoor.setTextColor(getActivity().getResources().getColor(R.color.colorBgWhite));
			}
			break;

		case R.id.rightFrontDoor:
			if(isclick5){
				isclick5=false;
				list.remove(item5);
				rightFrontDoor.setBackgroundResource(R.drawable.demaged_frame);
				rightFrontDoor.setTextColor(getActivity().getResources().getColor(R.color.colorTextOrange));
			}else{
				isclick5=true;
				list.add(item5);
				rightFrontDoor.setBackgroundResource(R.drawable.demaged_frame1);
				rightFrontDoor.setTextColor(getActivity().getResources().getColor(R.color.colorBgWhite));
			}
			break;

		case R.id.rightFrontFender:
			if(isclick6){
				isclick6=false;
				list.remove(item6);
				rightFrontFender.setBackgroundResource(R.drawable.demaged_frame);
				rightFrontFender.setTextColor(getActivity().getResources().getColor(R.color.colorTextOrange));
			}else{
				isclick6=true;
				list.add(item6);
				rightFrontFender.setBackgroundResource(R.drawable.demaged_frame1);
				rightFrontFender.setTextColor(getActivity().getResources().getColor(R.color.colorBgWhite));
			}
			break;


		default:
			break;
		}
	}
}
